﻿
Partial Class Login
    Inherits System.Web.UI.Page

    Protected Sub LinkButtonSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonSubmit.Click

        If TextBoxUsername.Text = String.Empty Then

            LabelMessage.Text = "Please Enter Username"
            LabelMessage.CssClass = "WarningMessage"

        ElseIf TextBoxPassword.Text = String.Empty Then

            LabelMessage.Text = "Please Enter Password"
            LabelMessage.CssClass = "WarningMessage"

        Else

            Dim SystemUser As SystemUser = DataSystemUser.Validate(TextBoxUsername.Text, TextBoxPassword.Text)


            If SystemUser Is Nothing Then

                LabelMessage.Text = "Invalid Credentials"
                LabelMessage.CssClass = "ErrorMessage"
            Else

                Session.Add("SystemUser", SystemUser)
                Response.Redirect("Default.aspx")

            End If
        End If
    End Sub

    Protected Sub LinkButtonRegister_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonRegister.Click
        Response.Redirect("Register.aspx")
    End Sub
End Class
